<?php

/*
 * Object/Transfert.php
 */

namespace RHX\Model\Object;

use Zend\Db\Adapter\Adapter;
use RHX\Model\Table\EmployeTable;
use RHX\Model\Table\SiteTable;

class Transfert {

    public $id;
    public $depart;
    public $arrivee;
    public $matricule;
    public $journee;
    public $entree;
    public $sortie;
    public $pause;
    public $repas;
    public $commentaire;
    protected $adapter;

    const EntrantSortant	 = 0;
    const Entrant		 = 1;
    const Sortant		 = 2;

    public function __construct(Adapter $adapter, $data = array()) {
	$this->adapter = $adapter;
	$this->exchangeArray($data);
    }

    public function exchangeArray($data) {
	$this->id		 = isset($data['id']) ? $data['id'] : null;
	$this->depart		 = isset($data['depart']) ? $data['depart'] : -1;
	$this->arrivee		 = isset($data['arrivee']) ? $data['arrivee'] : -1;
	$this->matricule	 = isset($data['matricule']) ? $data['matricule'] : 0;
	$this->journee		 = isset($data['jour']) ? $data['jour'] : '0000-00-00';
	$this->entree		 = isset($data['entree']) ? $data['entree'] : '00:00';
	$this->sortie		 = isset($data['sortie']) ? $data['sortie'] : '00:00';
	$this->pause		 = isset($data['pause']) ? $data['pause'] : 0;
	$this->repas		 = isset($data['repas']) ? $data['repas'] : 0;
	$this->commentaire	 = isset($data['commentaire']) ? $data['commentaire'] : null;
    }

    public function getArrayCopy() {
	return get_object_vars($this);
    }

    /**
     * Employé
     * 
     * @return Employe
     */
    public function getEmploye() {
	// Table employé
	$employeTable = new EmployeTable($this->adapter);

	$employe = $employeTable->get($this->matricule);

	return $employe;
    }

    /**
     * Site de départ
     * 
     * @return Site
     */
    public function getSiteDepart() {
	// Table site
	$siteTable = new SiteTable($this->adapter);

	$site = $siteTable->get($this->depart);

	return $site;
    }

    /**
     * Site d'arrivée
     * 
     * @return Site
     */
    public function getSiteArrivee() {
	// Table site
	$siteTable = new SiteTable($this->adapter);

	$site = $siteTable->get($this->arrivee);

	return $site;
    }

}
?>
